<?php

 
namespace RedMVC\Form\Element;
use RedMVC;

/**
 * Radios class
 *  
 * @category    RedMVC
 * @package     Form
 * @subpackage  Element 
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class Radios extends AElementMulti{

    private $delimiter = '<br>';

    public function setDelimiter($delimiter){
        $this->delimiter = $delimiter;
    }

    public function render(){
        $translate = RedMVC\Registry::get('RedMVC_Translate');
        $out = '<input type="hidden" name="'.$this->varname.'" value="" />';
        foreach($this->getOptions() as $value=>$name){		
    		$checked = ($this->getValue()==$value) ? ' checked="checked"' : '';
            $out .= '<label for="'.$this->varname.'-'.$value.'">';
            $out .= '  <input type="radio" id="'.$this->varname.'-'.$value.'" name="'.$this->varname.'" value="'.$value.'"'.$checked.' />'.$translate->_($name);
            $out .= '</label>'.$this->delimiter;
        }
        return $out;
    }
}